home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
Source
/
DBL Pascal Library
/
Animated Cursor
/
AnimatedCursor.p
Wrap
Text File
|
1991-01-17
|
1KB
|
63 lines
unit AnimatedCursor;
interface
type
acurState = record
which_acur, nextFrame: INTEGER;
nextTime: LONGINT;
end;
procedure Init_acur (theID: INTEGER; var theVars: acurState);
procedure Animate_acur (var theVars: acurState);
implementation
procedure Init_acur (theID: INTEGER; var theVars: acurState);
begin
with theVars do
begin
which_acur := theID;
nextFrame := 1;
nextTime := TickCount;
end;
end; { Init_acur }
procedure Animate_acur (var theVars: acurState);
const
minTicks = 2; {Never change frames faster than this}
type
acur = record
frames, ticks: INTEGER;
CURS_ids: array[1..1] of record
num, fill: INTEGER
end;
end;
acurPtr = ^acur;
acurHandle = ^acurPtr;
var
the_acur: acurHandle;
begin
with theVars do
begin
the_acur := acurHandle(GetResource('acur', which_acur));
if TickCount >= nextTime then
with the_acur^^ do
begin
HLock(Handle(the_acur));
if (nextFrame < 1) or (nextFrame > frames) then
nextFrame := 1;
{$PUSH}
{$R-}
SetCursor(GetCursor(CURS_ids[nextFrame].num)^^);
{$POP}
nextFrame := nextFrame + 1;
nextTime := nextTime + ticks;
if TickCount >= nextTime then {We're playing catch-up, or the acur resource is "hyperkinetic"}
nextTime := TickCount + 2;
HUnlock(Handle(the_acur));
end;
end;
end; { Animate_acur }
end.